# vector 创建
apple <- c("red","green","yellow");
print( apple );
# 查看类型
print( class( apple ));

# list 列表创建
ls = list(c(2,3,4),21.3,sin);
print( ls );

# Matrix 矩阵创建 注明:行和列
M = matrix(c('a','a','b','c','b','a'),nrow=2,ncol=3,byrow=TRUE);
print( M );
# 查看类型
print( class( M ));

# Array 数组创建
# 创建3*3矩阵元素个数为2
a<- array(c('green','yellow'),dim = c(3,3,2));
print( a );

# Factor 因子使用
apple_colors <- c("green","green","yellow","red","red","green");
factor_apple <- factor( apple_colors );
print( factor_apple );
# nlevels 统计级别计数
print(nlevels( factor_apple ));

# Data Frame 数据帧创建
BMI <- data.frame(
    gender = c("Male","Male","Female"),
    height = c(152,171.5,165),
    weight = c(81,93,78),
    Age = c(42,38,26)
);
print( BMI );
